<?php

class Application_Form_EntryAdd extends Zend_Form {

    public function init() {
        $this->setAction('/admin/entry/add')
                ->setMethod('post')
                ->setAttrib('id', 'entryForm')
                ->addElementPrefixPath('ZendBlog_Filter', 'ZendBlog/filter/', 'filter')
                ->setDecorators(ZendBlog_Decorator_Decorator::Form());

        /* Title */
        $this->addElement('text', 'title', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Title',
            'validators' => array(
              array('stringLength', false, array(3, 100))
            ),
            'attribs' => array(
                'maxlength' => 100,
                'size' => 40
            ),
            'required' => true
        ));

         /* Date */
        $this->addElement('text', 'date', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Date',
            'validators' => array(
                array('Date', false, array('yyyy-MM-dd HH:mm', 'en'))
            ),
            'attribs' => array(
                'maxlength' => 16,
                'size' => 16
            ),
            'value' => Zend_Date::now()->toString('yyyy-MM-dd HH:mm'),
            'required' => true
        ));

        /* Body */
        $this->addElement('textarea', 'body', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Body',
            'filters' => array('HtmlEntry'),
            'attribs' => array(
                'maxlength' => 500,
                'cols' => 50,
                'rows' => 15
            ),
            'required' => true
        ));

        /* Note */
        $this->addElement('note', 'note', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element()
        ));

        /* Login button */
        $this->addElement('submit', 'Add', array(
            'decorators' => ZendBlog_Decorator_Decorator::Submit()
        ));
    }
}

